package com.gf.demo.rabbitmqdemo.controller;

import com.gf.demo.rabbitmqdemo.dto.Dto1;
import com.gf.demo.rabbitmqdemo.dto.Dto2;
import com.gf.demo.rabbitmqdemo.dto.MqMessage;
import com.gf.framework.rabbitmq.core.GfRabbitTemplete;
import io.swagger.annotations.Api;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedList;

/**
 * @author gaofei
 * @date 2022/6/1 20:34
 */
@RestController
@Api(tags = "rabbitmq测试")
public class RabbitMqDemoController extends GfRabbitTemplete {
    @GetMapping("send")
    public Boolean send() {
        MqMessage message = new MqMessage();
        message.setBaseDtoList(new LinkedList<>());

        Dto1 dto1 = new Dto1();
        dto1.setId(1);
        dto1.setDto1("我是dto1");

        message.getBaseDtoList().add(dto1);

        Dto2 dto2 = new Dto2();
        dto2.setId(2);
        dto2.setDto2("我是dto2");

        message.getBaseDtoList().add(dto2);

        convertAndSend("gaofeitest", "123", message);
        return true;
    }

    @Override
    public void setMessageProperties(MessageProperties properties) {

    }
}
